#include "ellipse.h"

ellipse::ellipse(const point &upper_left,int a, int b):shape(upper_left)
{
	m_br = a;
	m_sr = b;
}

void ellipse::Draw(HWND hwnd,int xt, int yt)
{
	if(xt<100)
		xt=100;
	else if(xt>700)
		xt=700;
	if(yt>600)
		yt=600;
	SetBr((xt - m_pos.GetX())/2);
	SetSr((yt - m_pos.GetY())/2);

	HDC hdc = GetDC(hwnd);
	
		Ellipse(hdc,m_pos.GetX(),m_pos.GetY(),m_pos.GetX() + m_br*2,m_pos.GetY() + m_sr*2);


	ReleaseDC (hwnd, hdc) ;
}

void ellipse::Draw(HWND hwnd)
{

	HDC hdc = GetDC(hwnd);
	
		Ellipse(hdc,m_pos.GetX(),m_pos.GetY(),m_pos.GetX() + m_br*2,m_pos.GetY() + m_sr*2);

	ReleaseDC (hwnd, hdc) ;
}

void ellipse::Hide(HWND hwnd)
{

	HDC hdc = GetDC(hwnd);

		HPEN hPen = CreatePen (PS_SOLID,1,RGB(255,255,255));
		SelectObject (hdc, hPen);
		Ellipse(hdc,m_pos.GetX(),m_pos.GetY(),m_pos.GetX() + m_br*2,m_pos.GetY() + m_sr*2);
		DeleteObject(hPen);

	ReleaseDC (hwnd, hdc) ;
}

bool ellipse::operator==(const ellipse &right) const
{
	if(!(m_pos == right.m_pos))
		return false;
	if(m_br != right.GetBr() || m_sr != right.GetSr())
		return false;

	return true;
}

const ellipse& ellipse::operator =(const ellipse &right)
{
	if(this != &right)
	{
		m_pos = right.m_pos;
		SetBr(right.GetBr());
		SetSr(right.GetSr());
	}

	return *this;
}

ostream& operator<<(ostream &output,ellipse e)
{
	output << "pos = " << e.m_pos << "," << "big radius = " <<e.m_br << "," << "small radius = " << e.m_sr << endl;

	return output;
}